package com.hzzh.servlet;

import java.io.IOException;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hzzh.service.MeetingRoomService;
import com.hzzh.vo.MeetingRoom;

/**
 * Servlet implementation class AddMeetingRoomServlet
 */
@WebServlet("/AddMeetingRoomServlet")
public class AddMeetingRoomServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddMeetingRoomServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int roomnum=Integer.parseInt(request.getParameter("roomnum"));
		String roomname = request.getParameter("roomname");
		int capacity=Integer.parseInt(request.getParameter("capacity"));
		String status = request.getParameter("status");
		String description = request.getParameter("description");
		MeetingRoomService service = new MeetingRoomService();
		MeetingRoom mr = new MeetingRoom();
		mr.setRoomnum(roomnum);
		mr.setRoomname(roomname);
		mr.setCapacity(capacity);
		mr.setStatus(status);
		mr.setDescription(description);
		
		service.addMeetingRoom(mr);
		request.getRequestDispatcher("ViewAllMeetingRoomsServlet").forward(request, response);
		
		/*service.addMeetingRoom(new MeetingRoom(roomnum,roomname,capacity,status,description));*/
		
	}

}
